﻿/*!
* RapidForm JavaScript Library v1.0.0
* http://solutiongear.net/
*
* Copyright 2012, Ralph Luo
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://solutiongear.net/RapidForm/license
*
* Includes jquery.extensions.js
* Copyright 2012, The Xiamen SHENGUAN Software Technology Co., Ltd.
* Released under the MIT, BSD, and GPL Licenses.
*
* Date: 2012-03-06 14:24:03 
*/

var object = {    //定义小写的object基本类，用于实现最基础的方法等
    isA: function (aType) {   //一个判断类与类之间以及对象与类之间关系的基础方法
        var self = this;
        while (self) {
            if (self == aType)
                return true;
            self = self.Type;
        };
        return false;
    }
};

function Class(aBaseClass, aClassDefine) {    //创建类的函数，用于声明类及继承关系
    function class_() {   //创建类的临时函数壳
        this.Type = aBaseClass;    //我们给每一个类约定一个Type属性，引用其继承的类
        for (var member in aClassDefine)
            this[member] = aClassDefine[member];    //复制类的全部定义到当前创建的类
    };
    class_.prototype = aBaseClass;
    return new class_();
};

function New(aClass, aParams) {   //创建对象的函数，用于任意类的对象创建
    function new_() {    //创建对象的临时函数壳
        this.Type = aClass;    //我们也给每一个对象约定一个Type属性，据此可以访问到对象所属的类
        if (aClass.Create)
            aClass.Create.apply(this, aParams);   //我们约定所有类的构造函数都叫Create，这和DELPHI比较相似
    };
    new_.prototype = aClass;
    return new new_();
};

/////////////////////////////////////////////
/////////////////////////////////////////////  
//定义类型 ASPxRFMemo
var ASPxRFMemo = Class(object,
    {
        Create: function (controlID, groups, boundFields) {
            this.controlID = controlID;
            this.control = window[this.controlID];
            if (!this.control) {
                throw new Error(this.controlID + '控件不存在');
            }
            this.groups = groups;
            this.boundFields = boundFields;
            this.boundValues = '';
        },
        reset: function () {
            this.control.SetText('');
            this.boundValues = '';
        },
        setMarkFromData: function (data) {
            for (var item in data) {
                if (this.boundFields == item) {
                    this.boundValues = data[item];
                }
            }
        },
        setControlFromMark: function () {
            if (this.control.GetText() == this.boundValues) {
                return;
            }
            this.control.SetText(this.boundValues);
        },
        getMarkFromControl: function () {
            if (this.control.GetText()) {
                this.boundValues = this.control.GetText();
            } else {
                this.boundValues = '';
            }
        },
        getDataFromMark: function () {
            var result = {};
            result[this.boundFields] = this.boundValues;
            return result;
        }
    });

//定义类型ASPxRFCheckBox
var ASPxRFCheckBox = Class(object,
    {
        Create: function (controlID, groups, boundFields) {
            this.controlID = controlID;
            this.control = window[this.controlID];
            if (!this.control) {
                throw new Error(this.controlID + '控件不存在');
            }
            this.groups = groups;
            this.boundFields = boundFields;
            this.boundValues = '';
        },
        reset: function () {
            this.control.SetChecked(false);
            this.boundValues = false;
        },
        setMarkFromData: function (data) {
            for (var item in data) {
                if (this.boundFields == item) {
                    this.boundValues = data[item];
                }
            }
        },
        setControlFromMark: function () {
            if (this.control.GetChecked() == this.boundValues) {
                return;
            }
            this.control.SetChecked(this.boundValues);
        },
        getMarkFromControl: function () {
            this.boundValues = this.control.GetChecked();
        },
        getDataFromMark: function () {
            var result = {};
            result[this.boundFields] = this.boundValues;
            return result;
        }
    });

//定义类型ASPxRFHtmlEditor
var ASPxRFHtmlEditor = Class(object,
    {
        Create: function (controlID, groups, boundFields) {
            this.controlID = controlID;
            this.control = window[this.controlID];
            if (!this.control) {
                throw new Error(this.controlID + '控件不存在');
            }
            this.groups = groups;
            this.boundFields = boundFields;
            this.boundValues = '';
        },
        reset: function () {
            this.control.SetHtml('');
            this.boundValues = '';
        },
        setMarkFromData: function (data) {
            for (var item in data) {
                if (this.boundFields == item) {
                    this.boundValues = data[item];
                }
            }
        },
        setControlFromMark: function () {
            if (this.control.GetHtml() == this.boundValues) {
                return;
            }
            this.control.SetHtml(this.boundValues);
        },
        getMarkFromControl: function () {
            if (this.control.GetHtml()) {
                this.boundValues = this.control.GetHtml();
            } else {
                this.boundValues = '';
            }
        },
        getDataFromMark: function () {
            var result = {};
            result[this.boundFields] = this.boundValues;
            return result;
        }
    });


//定义类型ASPxRFGridLookup
    var ASPxRFGridLookup = Class(object,
    {
        Create: function (controlID, groups, selectionMode, boundFields, textFormatString) {
            this.controlID = controlID;
            this.control = window[this.controlID];
            this.groups = groups;
            this.selectionMode = selectionMode; //Multiple
            this.boundFields = boundFields;
            this.boundValues = [];
            this.textFormatString = textFormatString;
        },
        //重置
        reset: function () {
            this.control.SetText('');
            this.boundValues.length = 0;
        },
        //设置标记信息
        setMarkFromData: function (data) {
            for (var item in data) {
                for (var index in this.boundFields) {
                    if (this.boundFields[index] == item) {
                        this.boundValues[index] = data[item];
                    }
                }
            }
        },
        //根据标记值设置控件值
        setControlFromMark: function () {
            //单选
            if (this.selectionMode == 'Single') {
                var result = this.textFormatString;
                for (var i = 0; i < this.boundValues.length; i++) {
                    var patt = new RegExp("\\{" + i + "\\}", "g");
                    if (!patt.test(result)) {
                        throw new Error("formatString方法中索引为 " + (i + 1) + " 的参数无替换对象");
                    }
                    result = result.replace(patt, this.boundValues[i]);
                }
                this.control.SetText(result);
                //多选 ['重庆;南京;海南', '0111;0112;0113'] => [['重庆','0111'],['南京','0112'],['海南', '0113']]  => 重庆(0111);南京(0112);海南(0113)
            } else if (this.selectionMode == 'Multiple') {
                var values = this.convertArray(this.boundValues);
                result = '';

                for (var k = 0; k < values.length; k++) {
                    var formatString = this.textFormatString + ';';
                    //遍历数组元素的子元素
                    for (var j = 0; j < values[k].length; j++) {
                        var patt = new RegExp("\\{" + j + "\\}", "g");
                        if (!patt.test(formatString)) {
                            throw new Error("formatString方法中索引为 " + (j + 1) + " 的参数无替换对象");
                        }
                        formatString = formatString.replace(patt, values[k][j]);
                    }
                    result += formatString;
                }

                //删除最后一个分号;
                if (result.lastIndexOf(';') == result.length - 1) {
                    result = result.substring(0, result.length - 1);
                }
                this.control.SetText(result);
            }
        },
        //根据控件值获取标记值
        getMarkFromControl: function () {
            if (this.control.GetText()) {
                //控件值
                var text = this.control.GetText();
                //结果值
                var result;
                //绑定字段的数量
                var count = this.boundFields.length;
                //清空绑定值 
                this.boundValues.length = 0;

                //单选
                if (this.selectionMode == 'Single') {
                    //绑定多个字段
                    if (count > 1) {
                        var leftParenthesisIndex = text.indexOf('(');
                        var firstElement = text.substring(0, leftParenthesisIndex);
                        var others = text.substring(leftParenthesisIndex + 1, (text.length - 1));
                        result = others.split(',');
                        result.unshift(firstElement);
                        this.boundValues = result;
                        //绑定一个字段
                    } else {
                        this.boundValues.push(text);
                    }
                    //多选 
                    //示例：重庆(0111);南京(0112);海南(0113) => [['重庆','南京','海南'],['0111','0112','0113']] =>['重庆;南京;海南', '0111;0112;0113']
                } else if (this.selectionMode == 'Multiple') {
                    //构造参数parameter
                    var parameter = [];
                    for (var l = 0; l < count; l++) {
                        parameter[l] = [];
                    }
                    //控件值数组
                    var values = text.split(';');
                    //绑定多个字段
                    if (count > 1) {
                        //遍历

                        for (var i = 0; i < values.length; i++) {
                            var leftParenthesisIndex = values[i].indexOf('(');
                            var firstElement = values[i].substring(0, leftParenthesisIndex);
                            var others = values[i].substring(leftParenthesisIndex + 1, (values[i].length - 1));
                            result = others.split(',');
                            result.unshift(firstElement);
                            //数组项添加新元素 [['重庆','南京'],['0111','0112']] => [['重庆','南京','海南'],['0111','0112','0113']]
                            for (var j = 0; j < count; j++) {
                                parameter[j].push(result[j]);
                            }
                        }

                        //数组项由数组转化成字符串  [['重庆','南京','海南'],['0111','0112','0113']] =>['重庆;南京;海南', '0111;0112;0113']
                        for (var k = 0; k < parameter.length; k++) {
                            parameter[k] = parameter[k].join(';');
                        }

                        this.boundValues = parameter;
                        //绑定一个字段
                    } else {
                        this.boundValues.push(text);
                    }
                }
            } else {
                //this.boundValues.length = 0;
                for (var m = 0; m < this.boundValues.length; m++) {
                    this.boundValues[m] = '';
                }
            }
        },
        //从标记获取值
        getDataFromMark: function () {
            var result = {};
            for (var i = 0; i < this.boundFields.length; i++) {
                if (this.boundValues[i]) {
                    result[this.boundFields[i]] = this.boundValues[i];
                } else {
                    result[this.boundFields[i]] = null;
                }
            }
            return result;
        },
        convertArray: function (arg) {
            var fieldCount = arg.length;
            //校验参数
            var len = arg[0].split(';').length;
            for (var o = 0; o < arg.length; o++) {
                if (arg[o].split(';').length != len) {
                    throw new Error(arg[o] + '值不正确');
                }
            }

            var result = [];

            for (var i = 0; i < arg.length; i++) {
                var item = arg[i].split(';');
                //首次添加result数组项
                if (i == 0) {
                    for (var j = 0; j < item.length; j++) {
                        result.push([item[j]]);
                    }
                    //其他在result数组项中添加新项
                } else {
                    for (var k = 0; k < item.length; k++) {
                        for (var m = 0; m < result.length; m++) {
                            if (m == k) {
                                result[m].push(item[k]);
                            }
                        }
                    }
                }
            }

            return result;
        }
    });

//定义类型ASPxRFImage
var ASPxRFImage = Class(object,
    {
        Create: function (controlID, groups, boundFields, relativePath) {
            this.controlID = controlID;
            this.control = window[this.controlID];
            this.groups = groups;
            this.boundFields = boundFields;
            this.boundValues = '';
            this.relativePath = relativePath;
        },
        reset: function () {
            this.control.SetImageUrl(this.relativePath + 'noimage.png');
            this.boundValues = '';
        },
        setMarkFromData: function (data) {
            for (var item in data) {
                if (this.boundFields == item) {
                    this.boundValues = data[item];
                }
            }
        },
        setControlFromMark: function () {
            if (this.control.GetImageUrl() == (this.relativePath + this.boundValues)) {
                return;
            }
            this.control.SetImageUrl(this.relativePath + this.boundValues);
        },
        getMarkFromControl: function () {
            if (this.control.GetImageUrl()) {
                var url = this.control.GetImageUrl();
                url = url.substr(url.lastIndexOf('/') + 1)
                this.boundValues = url;
            } else {
                this.boundValues = '';
            }
        },
        getDataFromMark: function () {
            var result = {};
            result[this.boundFields] = this.boundValues;
            return result;
        }
    });

//定义类型ASPxRFHyperLink
    var ASPxRFHyperLink = Class(object,
    {
        Create: function (controlID, groups, boundFields, relativePath) {
            this.controlID = controlID;
            this.control = window[this.controlID];
            if (!this.control) {
                throw new Error(this.controlID + '控件不存在');
            }
            this.groups = groups;
            this.boundFields = boundFields;
            this.boundValues = '';
            this.relativePath = relativePath;
        },
        reset: function () {
            this.control.SetNavigateUrl('');
            this.boundValues = '';
        },
        setMarkFromData: function (data) {
            for (var item in data) {
                if (this.boundFields == item) {
                    this.boundValues = data[item];
                }
            }
        },
        setControlFromMark: function () {
            if (this.control.GetNavigateUrl == (this.relativePath + this.boundValues)) {
                return;
            }
            this.control.SetNavigateUrl(this.relativePath + this.boundValues);
        },
        getMarkFromControl: function () {
            if (this.control.GetNavigateUrl()) {
                var url = this.control.GetNavigateUrl();
                url = url.substr(url.lastIndexOf('/') + 1)
                this.boundValues = url;
            } else {
                this.boundValues = '';
            }
        },
        getDataFromMark: function () {
            var result = {};
            result[this.boundFields] = this.boundValues;
            return result;
        }
    });

    //定义类型ASPxRFLabel
    var ASPxRFLabel = Class(object,
    {
        Create: function (controlID, groups, boundFields, fieldType) {
            this.controlID = controlID;
            this.control = window[this.controlID];
            if (!this.control) {
                throw new Error(this.controlID + '控件不存在');
            }
            this.groups = groups;
            this.boundFields = boundFields;
            this.boundValues = '';
            //字段类型
            this.fieldType = fieldType;
            if (!this.fieldType) {
                this.fieldType = 'String';
            }
        },
        reset: function () {
            this.control.SetText('');
            this.boundValues = '';
        },
        setMarkFromData: function (data) {
            for (var item in data) {
                if (this.boundFields == item) {
                    var val = $.convertCustomTypeToString(data[item], this.fieldType);
                    //如果值是null，则转成‘’
                    if (val == null) {
                        this.boundValues = '';
                    } else {
                        this.boundValues = val;
                    }
                }
            }
        },
        setControlFromMark: function () {
            if (this.control.GetText() == this.boundValues) {
                return;
            }
            this.control.SetText(this.boundValues);
        },
        getMarkFromControl: function () {
            if (this.control.GetText()) {
                this.boundValues = this.control.GetText();
            } else {
                this.boundValues = '';
            }
        },
        getDataFromMark: function () {
            var result = {};
            result[this.boundFields] = $.convertStringToCustomType(this.boundValues, this.fieldType);
            return result;
        }
    });

//定义类型ASPxRFTextBox
    var ASPxRFTextBox = Class(object,
    {
        Create: function (controlID, groups, boundFields) {
            this.controlID = controlID;
            this.control = window[this.controlID];
            if (!this.control) {
                throw new Error(this.controlID + '控件不存在');
            }
            this.groups = groups;
            this.boundFields = boundFields;
            this.boundValues = '';
        },
        reset: function () {
            this.control.SetText('');
            this.boundValues = '';
        },
        setMarkFromData: function (data) {
            for (var item in data) {
                if (this.boundFields == item) {
                    this.boundValues = data[item];
                }
            }
        },
        setControlFromMark: function () {
            if (this.control.GetText() == this.boundValues) {
                return;
            }
            this.control.SetText(this.boundValues);
        },
        getMarkFromControl: function () {
            if (this.control.GetText()) {
                this.boundValues = this.control.GetText();
            } else {
                this.boundValues = '';
            }
        },
        getDataFromMark: function () {
            var result = {};
            result[this.boundFields] = this.boundValues;
            return result;
        }
    });

//定义类型ASPxRFDateEdit
    var ASPxRFDateEdit = Class(object,
    {
        Create: function (controlID, groups, boundFields, pattern) {
            this.controlID = controlID;
            this.control = window[this.controlID];
            if (!this.control) {
                throw new Error(this.controlID + '控件不存在');
            }
            this.groups = groups;
            this.boundFields = boundFields;
            this.boundValues = '';
            this.pattern = pattern;
        },
        reset: function () {
            this.control.SetDate(null);
            this.boundValues = null;
        },
        setMarkFromData: function (data) {
            for (var item in data) {
                if (this.boundFields == item) {
                    this.boundValues = data[item];
                }
            }
        },
        setControlFromMark: function () {
            if (this.control.GetDate() == this.boundValues) {
                return;
            }
            this.control.SetDate(this.boundValues);
        },
        getMarkFromControl: function () {
            if (this.control.GetDate()) {
                this.boundValues = this.control.GetDate();
            } else {
                this.boundValues = null;
            }
        },
        getDataFromMark: function () {
            var result = {};
            if (arguments.length == 0) {
                result[this.boundFields] = this.boundValues;
            } else if (arguments.length == 1) {
                result[this.boundFields] = $.formatDate(this.boundValues, arguments[0]);
            }
            return result;
        }
    });

//定义类型ASPxRFSpinEdit
    var ASPxRFSpinEdit = Class(object,
    {
        Create: function (controlID, groups, boundFields) {
            this.controlID = controlID;
            this.control = window[this.controlID];
            if (!this.control) {
                throw new Error(this.controlID + '控件不存在');
            }
            this.groups = groups;
            this.boundFields = boundFields;
            this.boundValues = '';
        },
        reset: function () {
            this.control.SetNumber('');
            this.boundValues = null;
        },
        setMarkFromData: function (data) {
            for (var item in data) {
                if (this.boundFields == item) {
                    this.boundValues = data[item];
                }
            }
        },
        setControlFromMark: function () {
            if (this.control.GetNumber() == this.boundValues) {
                return;
            }
            this.control.SetNumber(this.boundValues);
        },
        getMarkFromControl: function () {
            if (this.control.GetNumber() || this.control.GetNumber() == 0) {
                this.boundValues = this.control.GetNumber();
            } else {
                this.boundValues = null;
            }
        },
        getDataFromMark: function () {
            var result = {};
            result[this.boundFields] = this.boundValues;
            return result;
        }
    });

//定义类型ASPxRFTimeEdit
    var ASPxRFTimeEdit = Class(object,
    {
        Create: function (controlID, groups, boundFields, pattern) {
            this.controlID = controlID;
            this.control = window[this.controlID];
            if (!this.control) {
                throw new Error(this.controlID + '控件不存在');
            }
            this.groups = groups;
            this.boundFields = boundFields;
            this.boundValues = '';
            this.pattern = pattern;
        },
        reset: function () {
            this.control.SetDate(null);
            this.boundValues = null;
        },
        setMarkFromData: function (data) {
            for (var item in data) {
                if (this.boundFields == item) {
                    this.boundValues = data[item];
                }
            }
        },
        setControlFromMark: function () {
            if (this.control.GetDate() == this.boundValues) {
                return;
            }
            this.control.SetDate(this.boundValues);
        },
        getMarkFromControl: function () {
            if (this.control.GetDate()) {
                this.boundValues = this.control.GetDate();
            } else {
                this.boundValues = null;
            }
        },
        getDataFromMark: function () {
            var result = {};
            if (arguments.length == 0) {
                result[this.boundFields] = this.boundValues;
            } else if (arguments.length == 1) {
                result[this.boundFields] = $.formatDate(this.boundValues, arguments[0]);
            }
            return result;
        }
    });

//定义类型ASPxRFRadioButtonList {textFieldType:'String',valueFieldType:'Boolean'}
    var ASPxRFRadioButtonList = Class(object,
    {
        Create: function (controlID, groups, boundFields, fieldType) {
            this.controlID = controlID;
            this.control = window[this.controlID];
            if (!this.control) {
                throw new Error(this.controlID + '控件不存在');
            }
            this.groups = groups;
            this.boundFields = boundFields;

            if (this.boundFields.hasOwnProperty('textField') && this.boundFields.hasOwnProperty('valueField')) {
                this.boundType = 'Both';
                this.boundValues = { text: '', value: '' };
            } else if (this.boundFields.hasOwnProperty('textField')) {
                this.boundType = 'Text';
                this.boundValues = { text: '' };
            } else if (this.boundFields.hasOwnProperty('valueField')) {
                this.boundType = 'Value';
                this.boundValues = { value: '' };
            }

            //没有这个参数则采用默认
            if (!fieldType) {
                this.fieldType = { textFieldType: 'String', valueFieldType: 'String' };
            } else {
                this.fieldType = fieldType;
            }
        },
        reset: function () {
            this.control.SetSelectedIndex(-1);
            if (this.boundType == "Both") {
                this.boundValues = { text: '', value: '' };
            } else if (this.boundType == "Text") {
                this.boundValues = { text: '' };
            } else if (this.boundType == "Value") {
                this.boundValues = { value: '' };
            }
        },
        setMarkFromData: function (data) {
            for (var item in data) {
                for (var i in this.boundFields) {
                    if (this.boundFields[i] == item && i == 'textField') {
                        //转成String
                        this.boundValues.text = $.convertCustomTypeToString(data[item], this.fieldType.textFieldType);
                    } else if (this.boundFields[i] == item && i == 'valueField') {
                        //转成String
                        this.boundValues.value = $.convertCustomTypeToString(data[item], this.fieldType.valueFieldType);
                    }
                }
            }
        },
        setControlFromMark: function () {
            var length = this.control.GetItemCount();
            if (this.boundType == 'Value' || this.boundType == 'Both') {
                for (var i = 0; i < length; i++) {
                    var item = this.control.GetItem(i);
                    if (item.value == this.boundValues.value) {
                        this.control.SetSelectedIndex(i);
                        return;
                    }
                }
            } else if (this.boundType == 'Text') {
                for (var i = 0; i < length; i++) {
                    var item = this.control.GetItem(i);
                    if (item.text == this.boundValues.text) {
                        this.control.SetSelectedIndex(i);
                        return;
                    }
                }
            }
        },
        getMarkFromControl: function () {
            if (this.control.GetSelectedIndex() > -1) {
                var item = this.control.GetSelectedItem();
                if (this.boundType == "Both") {
                    this.boundValues.text = item.text;
                    this.boundValues.value = item.value;
                } else if (this.boundType == "Text") {
                    this.boundValues.text = item.text;
                } else if (this.boundType == "Value") {
                    this.boundValues.value = item.value;
                }
            }
        },
        getDataFromMark: function () {
            var result = {};
            if (this.boundType == "Both") {
                //按照目标字段，对取值进行类型转换
                result[this.boundFields.textField] = $.convertStringToCustomType(this.boundValues.text, this.fieldType.textFieldType);
                result[this.boundFields.valueField] = $.convertStringToCustomType(this.boundValues.value, this.fieldType.valueFieldType);
            } else if (this.boundType == "Text") {
                result[this.boundFields.textField] = $.convertStringToCustomType(this.boundValues.text, this.fieldType.textFieldType);
            } else if (this.boundType == "Value") {
                result[this.boundFields.valueField] = $.convertStringToCustomType(this.boundValues.value, this.fieldType.valueFieldType);
            }
            return result;
        }
    });

//定义类型ASPxRFCheckBoxList
var ASPxRFCheckBoxList = Class(object,
    {
        Create: function (controlID, groups, boundFields) {
            this.controlID = controlID;
            this.control = window[this.controlID];
            if (!this.control) {
                throw new Error(this.controlID + '控件不存在');
            }
            this.groups = groups;
            this.boundFields = boundFields;

            if (this.boundFields.hasOwnProperty('textField') && this.boundFields.hasOwnProperty('valueField')) {
                this.boundType = 'Both';
                this.boundValues = { text: '', value: '' };
            } else if (this.boundFields.hasOwnProperty('textField')) {
                this.boundType = 'Text';
                this.boundValues = { text: '' };
            } else if (this.boundFields.hasOwnProperty('valueField')) {
                this.boundType = 'Value';
                this.boundValues = { value: '' };
            }
        },
        reset: function () {
            this.control.UnselectAll();
            if (this.boundType == "Both") {
                this.boundValues = { text: '', value: '' };
            } else if (this.boundType == "Text") {
                this.boundValues = { text: '' };
            } else if (this.boundType == "Value") {
                this.boundValues = { value: '' };
            }
        },
        setMarkFromData: function (data) {
            for (var item in data) {
                for (var i in this.boundFields) {
                    if (this.boundFields[i] == item && i == 'textField') {
                        this.boundValues.text = data[item];
                    } else if (this.boundFields[i] == item && i == 'valueField') {
                        this.boundValues.value = data[item];
                    }
                }
            }
        },
        setControlFromMark: function () {
            //清空选中项
            this.control.UnselectAll();
            var length = this.control.GetItemCount();
            //选中项的索引数组
            var selectIndices = [];
            if (this.boundType == 'Value' || this.boundType == 'Both') {
                //绑定值数组
                var values = this.boundValues.value.split(';');
                for (var i = 0; i < length; i++) {
                    var item = this.control.GetItem(i);
                    for (var k in values) {
                        if (item.value == values[k]) {
                            selectIndices.push(i);
                        }
                    }
                }
            } else if (this.boundType == 'Text') {
                //绑定文本数组
                var text = this.boundValues.text.split(';');
                for (var j = 0; j < length; j++) {
                    item = this.control.GetItem(j);
                    for (var l in text) {
                        if (item.text == text[l]) {
                            selectIndices.push(i);
                        }
                    }
                }
            }
            //选中指定的项
            if (selectIndices.length > 0) {
                this.control.SelectIndices(selectIndices);
            }
        },
        getMarkFromControl: function () {
            //选中项
            var items = this.control.GetSelectedItems();
            if (items.length > 0) {
                var text = [];
                var values = [];
                //绑定文本和值
                if (this.boundType == "Both") {
                    for (var i in items) {
                        text.push(items[i].text);
                        values.push(items[i].value);
                    }
                    this.boundValues.text = text.join(';');
                    this.boundValues.value = values.join(';');
                    //绑定文本
                } else if (this.boundType == "Text") {
                    for (var j in items) {
                        text.push(items[j].text);
                    }
                    this.boundValues.text = text.join(';');
                    //绑定值
                } else if (this.boundType == "Value") {
                    for (var k in items) {
                        values.push(items[k].value);
                    }
                    this.boundValues.value = values.join(';');
                }
            } else {
                this.boundValues.text = '';
                this.boundValues.value = '';
            }
        },
        getDataFromMark: function () {
            var result = {};
            if (this.boundType == "Both") {
                result[this.boundFields.textField] = this.boundValues.text;
                result[this.boundFields.valueField] = this.boundValues.value;
            } else if (this.boundType == "Text") {
                result[this.boundFields.textField] = this.boundValues.text;
            } else if (this.boundType == "Value") {
                result[this.boundFields.valueField] = this.boundValues.value;
            }
            return result;
        }
    });


//定义类型ASPxRFComboBox
    var ASPxRFComboBox = Class(object,
    {
        Create: function (controlID, groups, boundFields, fieldType) {
            this.controlID = controlID;
            this.control = window[this.controlID];
            if (!this.control) {
                throw new Error(this.controlID + '控件不存在');
            }
            this.groups = groups;
            this.boundFields = boundFields;

            if (this.boundFields.hasOwnProperty('textField') && this.boundFields.hasOwnProperty('valueField')) {
                this.boundType = 'Both';
                this.boundValues = { text: '', value: '' };
            } else if (this.boundFields.hasOwnProperty('textField')) {
                this.boundType = 'Text';
                this.boundValues = { text: '' };
            } else if (this.boundFields.hasOwnProperty('valueField')) {
                this.boundType = 'Value';
                this.boundValues = { value: '' };
            }

            //没有这个参数则采用默认
            if (!fieldType) {
                this.fieldType = { textFieldType: 'String', valueFieldType: 'String'};
            }else{
                this.fieldType = fieldType;
            }
        },
        reset: function () {
            this.control.SetSelectedIndex(-1);
            if (this.boundType == "Both") {
                this.boundValues = { text: '', value: '' };
            } else if (this.boundType == "Text") {
                this.boundValues = { text: '' };
            } else if (this.boundType == "Value") {
                this.boundValues = { value: '' };
            }
        },
        setMarkFromData: function (data) {
            for (var item in data) {
                for (var i in this.boundFields) {
                    if (this.boundFields[i] == item && i == 'textField') {
                        this.boundValues.text = $.convertCustomTypeToString(data[item], this.fieldType.textFieldType);
                    } else if (this.boundFields[i] == item && i == 'valueField') {
                        this.boundValues.value = $.convertCustomTypeToString(data[item], this.fieldType.valueFieldType);
                    }
                }
            }
        },
        setControlFromMark: function () {
            var length = this.control.GetItemCount();
            if (this.boundType == 'Value' || this.boundType == 'Both') {
                for (var i = 0; i < length; i++) {
                    var item = this.control.GetItem(i);
                    if (item.value == this.boundValues.value) {
                        this.control.SetSelectedIndex(i);
                        return;
                    }
                }
            } else if (this.boundType == 'Text') {
                for (var i = 0; i < length; i++) {
                    var item = this.control.GetItem(i);
                    if (item.text == this.boundValues.text) {
                        this.control.SetSelectedIndex(i);
                        return;
                    }
                }
            }
        },
        getMarkFromControl: function () {
            if (this.control.GetSelectedIndex() > -1) {
                var item = this.control.GetSelectedItem();
                if (this.boundType == "Both") {
                    this.boundValues.text = item.text;
                    this.boundValues.value = item.value;
                } else if (this.boundType == "Text") {
                    this.boundValues.text = item.text;
                } else if (this.boundType == "Value") {
                    this.boundValues.value = item.value;
                }
            }
        },
        getDataFromMark: function () {
            var result = {};
            if (this.boundType == "Both") {
                //按照目标字段，对取值进行类型转换
                result[this.boundFields.textField] = $.convertStringToCustomType(this.boundValues.text, this.fieldType.textFieldType);
                result[this.boundFields.valueField] = $.convertStringToCustomType(this.boundValues.value, this.fieldType.valueFieldType);
            } else if (this.boundType == "Text") {
                result[this.boundFields.textField] = $.convertStringToCustomType(this.boundValues.text, this.fieldType.textFieldType);
            } else if (this.boundType == "Value") {
                result[this.boundFields.valueField] = $.convertStringToCustomType(this.boundValues.value, this.fieldType.valueFieldType);
            }
            return result;
        }
    });

//定义类型ASPxRFDropDownEdit
var ASPxRFDropDownEdit = Class(object,
    {
        Create: function (controlID, listBoxID, groups, boundFields) {
            this.controlID = controlID;
            this.control = window[this.controlID];
            if (!this.control) {
                throw new Error(this.controlID + '控件不存在');
            }
            this.listBoxID = listBoxID;
            this.listBox = window[this.listBoxID];
            if (!this.listBox) {
                throw new Error(this.listBoxID + '控件不存在');
            }

            this.groups = groups;
            this.boundFields = boundFields;

            if (this.boundFields.hasOwnProperty('textField') && this.boundFields.hasOwnProperty('valueField')) {
                this.boundType = 'Both';
                this.boundValues = { text: '', value: '' };
            } else if (this.boundFields.hasOwnProperty('textField')) {
                this.boundType = 'Text';
                this.boundValues = { text: '' };
            } else if (this.boundFields.hasOwnProperty('valueField')) {
                this.boundType = 'Value';
                this.boundValues = { value: '' };
            }
        },
        reset: function () {
            this.control.SetText('');
            SynchronizeListBox(this.control, this.listBox);

            if (this.boundType == "Both") {
                this.boundValues = { text: '', value: '' };
            } else if (this.boundType == "Text") {
                this.boundValues = { text: '' };
            } else if (this.boundType == "Value") {
                this.boundValues = { value: '' };
            }
        },
        setMarkFromData: function (data) {
            for (var item in data) {
                for (var i in this.boundFields) {
                    if (this.boundFields[i] == item && i == 'textField') {
                        this.boundValues.text = data[item];
                    } else if (this.boundFields[i] == item && i == 'valueField') {
                        this.boundValues.value = data[item];
                    }
                }
            }
        },
        setControlFromMark: function () {
            //清空选中项
            this.listBox.UnselectAll();
            var length = this.listBox.GetItemCount();
            //选中项的索引数组
            var selectIndices = [];
            if (this.boundType == 'Value' || this.boundType == 'Both') {
                //绑定值数组
                var values = this.boundValues.value.split(';');
                for (var i = 0; i < length; i++) {
                    var item = this.listBox.GetItem(i);
                    for (var k in values) {
                        if (item.value == values[k]) {
                            selectIndices.push(i);
                        }
                    }
                }
            } else if (this.boundType == 'Text') {
                //绑定文本数组
                var text = this.boundValues.text.split(';');
                for (var j = 0; j < length; j++) {
                    item = this.listBox.GetItem(j);
                    for (var l in text) {
                        if (item.text == text[l]) {
                            selectIndices.push(i);
                        }
                    }
                }
            }
            //选中指定的项
            if (selectIndices.length > 0) {
                this.listBox.SelectIndices(selectIndices);
            }
            UpdateSelectAllItemState(this.listBox);
            UpdateText(this.control, this.listBox);
        },
        getMarkFromControl: function () {
            //选中项
            var items = this.listBox.GetSelectedItems();
            if (items.length > 0) {
                var text = [];
                var values = [];
                //绑定文本和值
                if (this.boundType == "Both") {
                    for (var i in items) {
                        text.push(items[i].text);
                        values.push(items[i].value);
                    }
                    this.boundValues.text = text.join(';');
                    this.boundValues.value = values.join(';');
                    //绑定文本
                } else if (this.boundType == "Text") {
                    for (var j in items) {
                        text.push(items[j].text);
                    }
                    this.boundValues.text = text.join(';');
                    //绑定值
                } else if (this.boundType == "Value") {
                    for (var k in items) {
                        values.push(items[k].value);
                    }
                    this.boundValues.value = values.join(';');
                }
            } else {
                this.boundValues.text = '';
                this.boundValues.value = '';
            }
        },
        getDataFromMark: function () {
            var result = {};
            if (this.boundType == "Both") {
                result[this.boundFields.textField] = this.boundValues.text;
                result[this.boundFields.valueField] = this.boundValues.value;
            } else if (this.boundType == "Text") {
                result[this.boundFields.textField] = this.boundValues.text;
            } else if (this.boundType == "Value") {
                result[this.boundFields.valueField] = this.boundValues.value;
            }
            return result;
        }
    });

//下拉框改变事件
function OnListBoxSelectionChanged(listBox, args) {
    ListBoxSelectionChanged(ddeRole, listBox, args);
}
function ListBoxSelectionChanged(dropDownEdit, checkListBox, args) {
    if (args.index == 0)
        args.isSelected ? checkListBox.SelectAll() : checkListBox.UnselectAll();
    UpdateSelectAllItemState(checkListBox);
    UpdateText(dropDownEdit, checkListBox);
}

//文本改变事件和下拉事件
function SynchronizeListBoxValues(dropDown, args) {
    SynchronizeListBox(dropDown, checkListBox);
}
function SynchronizeListBox(dropDownEdit, checkListBox) {
    checkListBox.UnselectAll();
    var texts = dropDownEdit.GetText().split(";");
    var values = GetValuesByTexts(texts);
    checkListBox.SelectValues(values);
    UpdateSelectAllItemState(checkListBox);
    UpdateText(dropDownEdit, checkListBox);
}

//判断是否选中全部项，如果是则第一项选中，否则第一项不选中
function UpdateSelectAllItemState(checkListBox) {
    IsAllSelected(checkListBox) ? checkListBox.SelectIndices([0]) : checkListBox.UnselectIndices([0]);
}
//判断列表框是否全部选中
function IsAllSelected(checkListBox) {
    var selectedDataItemCount = checkListBox.GetItemCount() - (checkListBox.GetItem(0).selected ? 0 : 1);
    return checkListBox.GetSelectedItems().length == selectedDataItemCount;
}
//根据下拉选中项，得到文本框值
function UpdateText(dropDownEdit, checkListBox) {
    var selectedItems = checkListBox.GetSelectedItems();
    dropDownEdit.SetText(GetSelectedItemsText(selectedItems));
}
//根据下拉框的选中项，得到文本框的值
function GetSelectedItemsText(items) {
    var texts = [];
    for (var i = 0; i < items.length; i++)
        if (items[i].index != 0)
            texts.push(items[i].text);
    return texts.join(';');
}
//根据文本框的值，得到选中项的数组值
function GetValuesByTexts(texts) {
    var actualValues = [];
    var item;
    for (var i = 0; i < texts.length; i++) {
        item = checkListBox.FindItemByText(texts[i]);
        if (item != null)
            actualValues.push(item.value);
    }
    return actualValues;
}

//////////////////////////////////
//////////////////////////////////
//定义类型RapidForm
var RapidForm = Class(object,
{
    Create: function (arg) {
        this.controlCollection = this.createControlCollection(arg);
        this.groupsInfo = this.createGroupsInfo(this.controlCollection);

    },
    //给控件标记添加索引属性
    createControlCollection: function (arg) {
        for (var i = 0; i < arg.length; i++) {
            arg[i].index = i;
        }
        return arg;
    },
    //初始化属性groupsInfo
    createGroupsInfo: function (arg) {
        var result = {};
        var groups = [];
        //遍历所有控件
        for (var i = 0; i < arg.length; i++) {
            //遍历每个控件组信息
            for (var j = 0; j < arg[i].groups.length; j++) {
                //如果此组没有存在结果中，则添加到结果中
                if ($.inArray(arg[i].groups[j], groups) < 0) {
                    groups.push(arg[i].groups[j]);
                    result[arg[i].groups[j]] = [];
                }
            }
        }

        for (var k = 0; k < groups.length; k++) {
            for (var l = 0; l < arg.length; l++) {
                if ($.inArray(groups[k], arg[l].groups) >= 0) {
                    result[groups[k]].push(l);
                }
            }
        }
        return result;
    },
    //根据控件ID，返回控件标记索引，如果无此控件标记，则返回-1
    getControlIndexByID: function (arg) {
        for (var i = 0; i < this.controlCollection.length; i++) {
            if (this.controlCollection[i].controlID == arg) {
                return this.controlCollection[i].index;
            }
        }
        return -1;
    },
    //根据组名和排除控件ID，查找控件标记
    //arg[0] groups
    //arg[1] executeID
    getControlCollection: function (arg) {
        var groupsName = arg[0].split(',');
        var indexs = [];
        //根据输入组名，遍历组信息，然后合并所有对应控件索引
        for (var i in this.groupsInfo) {
            //成员变量是对象类型的
            if (typeof this.groupsInfo[i] == 'object') {
                for (var j = 0; j < groupsName.length; j++) {
                    if (i == groupsName[j]) {
                        indexs = $.merge(indexs, this.groupsInfo[i]);
                    }
                }

            }
        }
        //去除重复的数组值
        indexs = $.uniqueArray(indexs);

        if (arg.length >= 2) {
            var excludedID = arg[1].split(',');
            var self = this;
            //从indexs中去除指定控件ID的索引
            indexs = $.grep(indexs, function (val, key) {
                for (var i = 0; i < excludedID.length; i++) {
                    if (self.getControlIndexByID(excludedID[i]) == val) {
                        return false;
                    }
                }
                return true;
            });
        }
        //获取控件数组集合
        var result = [];
        for (var k = 0; k < indexs.length; k++) {
            result.push(this.controlCollection[indexs[k]]);
        }
        return result;
    },
    //重置控件
    reset: function () {
        var controls = this.getControlCollection(arguments);
        for (var i = 0; i < controls.length; i++) {
            controls[i].reset();
        }
    },
    //更新控件
    update: function (data, groupsName, constrolsID) {
        var data = arguments[0];
        var arg = [];
        if (arguments.length == 2) {
            arg[0] = arguments[1];
        } else if (arguments.length == 3) {
            arg[0] = arguments[1];
            arg[1] = arguments[2];
        }
        var controls = this.getControlCollection(arg);
        //遍历指定控件
        for (var index in controls) {
            //遍历输入数据的字段名
            for (var property in data) {
                //如果控件有绑定输入数据的字段名，则更新
                if (this.isContainFieldName(property, controls[index].boundFields)) {
                    controls[index].setMarkFromData(data);
                    controls[index].setControlFromMark();
                }
            }
        }
    },
    //获取数据
    get: function () {
        var result = {};
        var ret = {};
        var data;
        var controls = this.getControlCollection(arguments);
        for (var i = 0; i < controls.length; i++) {
            controls[i].getMarkFromControl();
            data = controls[i].getDataFromMark();
            for (var property in data) {
                result[property] = data[property];
            }
        }
        //值不为null, '',Function类型
        for (var item in result) {
            if (result[item] != null && result[item] != '' && !(result[item] instanceof Function)) {
                ret[item] = result[item];
            }
        }
        return ret;
    },
    //获取数据构造成成查询字符串
    getQueryString: function () {
        var result = {};
        var data;
        //获取控件集合
        var controls = this.getControlCollection(arguments);
        //获取字段信息
        for (var index = 0; index < controls.length; index++) {
            controls[index].getMarkFromControl();
            data = controls[index].getDataFromMark();
            for (var property in data) {
                //如果参数是日期类型则转换成字符串($.param(),对Date类型属性无法转换)
                if (data[property] instanceof Date) {
                    result[property] = $.formatDate(data[property], 'yyyy-MM-dd');
                    continue;
                }
                //如果参数是null，则转换成空字符串
                if (data[property] == null) {
                    result[property] = '';
                    continue;
                }

                result[property] = data[property];
            }
        }
        //对象序列化成查询字符串
        return $.param(result);
    },
    //判断控件的boundFields是否包含字段field
    isContainFieldName: function (fieldName, boundFields) {
        if ((typeof boundFields).toLocaleString() == 'string') {
            if (boundFields == fieldName) {
                return true;
            }
            return false;
        } else if (boundFields instanceof Array) {
            if ($.inArray(fieldName, boundFields) >= 0) {
                return true;
            }
            return false;
        } else if (boundFields instanceof Object) {
            for (var property in boundFields) {
                if (boundFields[property] == fieldName) {
                    return true;
                }
            }
            return false;
        }
    },
    //是否启用 
    //启用控件 ControlsCollection.setEnabled(true,'GroupA','abc');
    setEnabled: function () {

        var arr = [];
        var firstArg = arguments[0];
        arr[0] = arguments[1];
        if (typeof arguments[2] == 'string') {
            arr[1] = arguments[2];
        }

        //获取控件集合
        var controls = this.getControlCollection(arr);
        //获取字段信息
        for (var index = 0; index < controls.length; index++) {
            controls[index].control.SetEnabled(firstArg);
        }
    }
});
/*******************************************/
//定义类型RapidForm 概览界面类
var RFPage = Class(object,
{
    Create: function () {//构造函数
        this.menu = arguments[0];
        this.gridView = arguments[1];
        this.singleOperatingButton = arguments[2];
        this.batchOperationButton = arguments[3];
        this.viewButton = arguments[4];
        //无显示列表状态下的按钮，则添加默认
        if (!this.viewButton) {
            this.viewButton = ['btnRefresh', 'btnExport'];
        }
        this.navigationInfo = arguments[5];
        //如果导航信息的URL Format属性没有设置，则给出默认值
        if (this.navigationInfo && !this.navigationInfo.itemUrlFormat) {
            this.navigationInfo.itemUrlFormat = 'Views/{0}/Common/{1}.aspx';
        }
    },
    firstLoad: function () {//页面首次加载
        var collection = this.singleOperatingButton.concat(this.batchOperationButton);
        this.setEnableByButtonName(collection, false);
    },
    setEnableByButtonName: function (buttonName, isEnable) {//启用或者禁用制定的按钮
        for (var i = 0; i < buttonName.length; i++) {
            var menuItem = this.menu.GetItemByName(buttonName[i]);
            if (menuItem) {
                menuItem.SetEnabled(isEnable);
            }
        }
    },
    selectionChanged: function () { //GridView选择改变事件
        var selectedCount = this.gridView.GetSelectedRowCount();
        if (selectedCount == 0) {//没有选中，
            var collection = this.singleOperatingButton.concat(this.batchOperationButton);
            this.setEnableByButtonName(collection, false);
        } else if (selectedCount == 1) {//选中一条
            collection = this.singleOperatingButton.concat(this.batchOperationButton);
            this.setEnableByButtonName(collection, true);
        } else if (selectedCount > 1) {//选中多条
            this.setEnableByButtonName(this.singleOperatingButton, false);
            this.setEnableByButtonName(this.batchOperationButton, true);
        }
    },
    toSearch: function () { //进行查找
        this.setEnableByButtonName(this.viewButton, false);
        var collection = this.singleOperatingButton.concat(this.batchOperationButton);
        this.setEnableByButtonName(collection, false);
    },
    toListAll: function () {//显示
        this.setEnableByButtonName(this.viewButton, true);
        this.selectionChanged();
        //显示列表按钮被选中
        this.menu.SetSelectedItem(this.menu.GetItemByName('btnListAll'));
    },
    rowDblClick: function (s, e) { //GridView行双击事件
        if (!this.navigationInfo) {
            throw new Error('无导航信息');
        }
        var keyid = this.gridView.GetRowKey(e.visibleIndex);
        //构造导航URL 
        var url = $.formatString(this.navigationInfo.itemUrlFormat, this.navigationInfo.moduleValue, this.navigationInfo.itemValue);
        url += '?State=Load&Keyid=' + keyid;
        //打开新的选项卡页面
        parent.navTab.openTab(url, url, { title: this.navigationInfo.itemName, fresh: false, external: true, data: {} });
    },
    toAdd: function () { //新增
        var autoId = new Date().getTime().toString();
        //构造导航URL
        var url = $.formatString(this.navigationInfo.itemUrlFormat, this.navigationInfo.moduleValue, this.navigationInfo.itemValue);
        url += '?State=Add';
        //构造tabId
        var tabId = url + '&AutoId=' + autoId;
        parent.navTab.openTab(tabId, url, { title: this.navigationInfo.itemName, fresh: true, external: true, data: {} });
    },
    toEdit: function () {//编辑
        var keyid = gvwList.GetSelectedKeysOnPage()[0];
        var url = $.formatString(this.navigationInfo.itemUrlFormat, this.navigationInfo.moduleValue, this.navigationInfo.itemValue);
        url += '?State=Edit&Keyid=' + keyid;
        parent.navTab.openTab(url, url, { title: this.navigationInfo.itemName, fresh: true, external: true, data: {} });
    },
    toView: function () {//明细
        var keyid = gvwList.GetSelectedKeysOnPage()[0];
        //构造导航URL
        var url = $.formatString(this.navigationInfo.itemUrlFormat, this.navigationInfo.moduleValue, this.navigationInfo.itemValue);
        url += '?State=Load&Keyid=' + keyid;
        //打开新的选项卡页面
        parent.navTab.openTab(url, url, { title: this.navigationInfo.itemName, fresh: false, external: true, data: {} });
    }
});

////////////////////////////////////////////////
//定义类型TreeList RapidForm 概览界面类
var RFTreeListPage = Class(object,
{
    Create: function () {//构造函数
        this.menu = arguments[0];
        this.treeList = arguments[1];
        this.singleOperatingButton = arguments[2];
        //this.batchOperationButton = arguments[3];
        this.viewButton = arguments[3];
        //无显示列表状态下的按钮，则添加默认
        if (!this.viewButton) {
            this.viewButton = ['btnRefresh', 'btnExport'];
        }
        this.navigationInfo = arguments[4];
        //如果导航信息的URL Format属性没有设置，则给出默认值
        if (this.navigationInfo && !this.navigationInfo.itemUrlFormat) {
            this.navigationInfo.itemUrlFormat = 'Views/{0}/Common/{1}.aspx';
        }
    },
    setEnableByButtonName: function (buttonName, isEnable) {//启用或者禁用制定的按钮
        for (var i = 0; i < buttonName.length; i++) {
            var menuItem = this.menu.GetItemByName(buttonName[i]);
            if (menuItem) {
                menuItem.SetEnabled(isEnable);
            }
        }
    },
    toSearch: function () { //进行查找
        this.setEnableByButtonName(this.viewButton, false);
        var collection = this.singleOperatingButton;
        this.setEnableByButtonName(collection, false);
    },
    toListAll: function () {//显示
        this.setEnableByButtonName(this.viewButton, true);
        this.setEnableByButtonName(this.singleOperatingButton, true);
        //显示列表按钮被选中
        this.menu.SetSelectedItem(this.menu.GetItemByName('btnListAll'));
    },
    toNodeDblClick: function (s, e) { //TreeList行双击事件
        if (!this.navigationInfo) {
            throw new Error('无导航信息');
        }
        var keyid = e.nodeKey;
        //构造导航URL
        var url = $.formatString(this.navigationInfo.itemUrlFormat, this.navigationInfo.moduleValue, this.navigationInfo.itemValue);
        url += '?State=Load&Keyid=' + keyid;
        //打开新的选项卡页面
        parent.navTab.openTab(url, url, { title: this.navigationInfo.itemName, fresh: false, external: true, data: {} });
    },
    toAddSibling: function () { //新增同级
        var keyid = this.treeList.GetFocusedNodeKey();
        //导航信息
        var navigationInfo = this.navigationInfo;
        this.treeList.GetNodeValues(keyid, 'ParentKeyid', function (result) {//result是ParentKeyid字段值
            var autoId = new Date().getTime().toString();
            //构造导航URL
            var url = $.formatString(navigationInfo.itemUrlFormat, navigationInfo.moduleValue, navigationInfo.itemValue);
            url += '?State=AddSibling';
            url += '&ParentKeyid=' + result;
            //构造tabId
            var tabId = url + '&AutoId=' + autoId;
            parent.navTab.openTab(tabId, url, { title: navigationInfo.itemName, fresh: true, external: true, data: {} });
        });
    },
    toAddSubordinate: function () { //新增下级
        var keyid = this.treeList.GetFocusedNodeKey();
        var autoId = new Date().getTime().toString();
        //构造导航URL
        var url = $.formatString(this.navigationInfo.itemUrlFormat, this.navigationInfo.moduleValue, this.navigationInfo.itemValue);
        url += '?State=AddSubordinate';
        url += '&ParentKeyid=' + keyid;
        //构造tabId
        var tabId = url + '&AutoId=' + autoId;
        parent.navTab.openTab(tabId, url, { title: this.navigationInfo.itemName, fresh: true, external: true, data: {} });
    },
    toEdit: function () {//编辑
        var keyid = this.treeList.GetFocusedNodeKey();
        var url = $.formatString(this.navigationInfo.itemUrlFormat, this.navigationInfo.moduleValue, this.navigationInfo.itemValue);
        url += '?State=Edit&Keyid=' + keyid;
        parent.navTab.openTab(url, url, { title: this.navigationInfo.itemName, fresh: true, external: true, data: {} });
    },
    toView: function () {//明细
        var keyid = this.treeList.GetFocusedNodeKey();
        //构造导航URL
        var url = $.formatString(this.navigationInfo.itemUrlFormat, this.navigationInfo.moduleValue, this.navigationInfo.itemValue);
        url += '?State=Load&Keyid=' + keyid;
        //打开新的选项卡页面
        parent.navTab.openTab(url, url, { title: this.navigationInfo.itemName, fresh: false, external: true, data: {} });
    }
});
